package operation;

import student.Student;
import student.StudentList;

import java.util.Scanner;

public class ModifOperation implements IOperation{
    @Override
    public void work(StudentList list) {
        System.out.println("修改学生消息");
        System.out.println("请输入你要修改的学生学号:->");
        Scanner sc = new Scanner(System.in);
        String stuId = sc.next();
        int sz = list.size();
        int i = 0;
        for(; i < sz; i++){
            Student stu = list.get(i);
            if(stu.getStudentId().equals(stuId)){
                System.out.println("请输入修改的姓名");
                String name = sc.next();
                System.out.println("请输入修改的性别");
                String sex = sc.next();
                System.out.println("请输入修改的身份证");
                String id = sc.next();
                System.out.println("请输入修改的电话");
                String tele = sc.next();
                System.out.println("请输入修改的年龄");
                int age = sc.nextInt();
                Student stu1 = new Student(stuId,name,age,sex,id,tele);
                list.set(i,stu1);
                System.out.println("修改成功");
                return;
            }
        }
        if(i == sz){
            System.out.println("为找到要修改的学生");
        }
    }
}
